// 价牌管理接口
import { default as request, download } from '@/utils/request'
// import { getUser, getToken } from '@/utils/auth'
import qs from 'qs'

// 按照场站id获取设备列表
export function getEtagList(data, stationId) {
  if (!stationId) stationId = '0'
  return request({
    url: '/etag/get/station/' + stationId,
    method: 'post',
    data
  })
}

// 添加价牌模板
export function addEtag(data) {
  return request({
    url: '/etag/add/with/template',
    method: 'post',
    data
  })
}

// 批量添加价牌模板
export function batchAddEtag(data) {
  return request({
    url: '/etag/add/batch',
    method: 'post',
    data
  })
}

// 修改价牌模板
export function putEtag(data) {
  return request({
    url: '/etag/edit',
    method: 'post',
    data
  })
}

// 删除价牌模板
export function delEtag(data) {
  return request({
    url: '/etag/del/' + data.etagId,
    method: 'delete',
    headers: { 'content-type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(data)
  })
}

// 批量删除价牌
export function delEtagBatch(ids) {
  return request({
    url: '/etag/delBatch/' + ids,
    method: 'delete',
    headers: { 'content-type': 'application/x-www-form-urlencoded' }
  })
}

// 导出数据
export function exportEtag(data) {
  return request({
    url: '/etag/download',
    method: 'post',
    data,
    responseType: 'arraybuffer'
  }).then(res => {
    return download(res)
  })
}
